package com.example.springboot.controller.admin;

import com.example.springboot.model.enums.ResultCodeEnum;
import com.example.springboot.model.form.Result;
import com.example.springboot.model.req.admin.MetasReq;
import com.example.springboot.service.admin.MetasService;
import com.example.springboot.utils.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author zf
 * @version 1.0
 * @ClassName MetasController
 * @分类表
 * @since 2021-03-17
 */
@RestController
@RequestMapping("/metas")
public class MetasController {

    @Resource
    private MetasService service;

    /**
     * @param req
     * @Description: 列表
     */
    @PostMapping("/list")
    public Result list(MetasReq req) {
        return service.getPage(req);
    }

    /**
     * @param req
     * @Description: 新增
     */
    @PostMapping("/save")
    public Result save(MetasReq req) {
        return service.addInfo(req);
    }

    /**
     * @param ids
     * @Description: 批量删除
     */
    @PostMapping("/deleteIds")
    public Result deleteInfos(String ids) {
        Assert.isNull(ids, ResultCodeEnum.CLIENT_PARAM_ERROR);
        return service.deleteInfos(ids);
    }
}

